package com.yl.chainStore.pojo.vo.customer

import com.baomidou.mybatisplus.annotation.TableField
import com.yl.chainStore.common.enums.TypeEnum
import com.yl.chainStore.entity.pay.PayCustomerAccount
import com.yl.chainStore.entity.pay.PayItemCustomerShowRule
import com.yl.chainStore.entity.sick.SickMedicalRecordsDetail
import com.yl.chainStore.util.getAge
import java.text.SimpleDateFormat
import java.util.*

/**
 * 客户信息，返回用
 */
data class CustomerResultVo (
	val id:Long,

	val name:String,

	var gender: TypeEnum,

	var mobileNum: String? = null,

	var historySickNum:String?=null,

	var createUserName:String ?= null,

	var createTime:Date,

	var lastDoctorId:Long ?= null,

	var lastDoctorName:String ?= null,

	var lastConsultantId:Long ?= null,

	var lastConsultantName:String ?= null,

	var lastSickRecordTime:Date?=null,

	var remark:String ?= null,

	var source:String?=null,
	/**
	 * 生日
	 */
	var birthDate: Date? = null,

	//新版来源
	var sourceShow:String?=null,

	var toDaySubscribeStartTime:Date?=null,

	var toDaySubscribeTime:Int?=null,

	var toDaySubscribeDoctorName:String?=null,

	var toDaySubscribeItemNames:String ?= null,

	var showRules:List<PayItemCustomerShowRule>?=null,

	var lastRecordsDetail:SickMedicalRecordsDetail ?=null,

	var account: PayCustomerAccount ?= null,

	var hasArrearsOrder:Boolean ?= null,

	){
		val toDaySubscribeStartTimeShow:String

			get() {
				if(toDaySubscribeStartTime != null && toDaySubscribeTime != null){
					val sdf = SimpleDateFormat("HH:mm")
					val c = Calendar.getInstance()
					c.time = toDaySubscribeStartTime
					c.add(Calendar.MINUTE, toDaySubscribeTime!!)
					return sdf.format(toDaySubscribeTime) + "-"+sdf.format(c.time)
				}
				return ""
			}

	val toDaySubscribeTimeShow:String
		get() {
			if( toDaySubscribeTime != null){
				return toDaySubscribeTime.toString()+"分钟"
			}

			return ""
		}

	val age: Int?
		get() {
			if (birthDate != null) {
				return getAge(birthDate!!)
			}
			return null
		}
}
